home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / html / docopy.sh next >
Linux/UNIX/POSIX Shell Script  |  1997-07-24  |  11KB  |  212 lines

  1. #!/bin/sh  
  2. ########
  3. # SWISH installation script for Hot Mix 17.
  4. # G. Helms, 7/23/97
  5. # My profoundest apologies for the horrible condition of this script.
  6. # If you think THIS is bad, you should have seen the previous version!
  7. # I apologize in advance if you have to wade through this muck.  
  8. # If you have any questions, I can be reached at ghelms@sgi.com and can 
  9. # help you with any problems.
  10. ########
  11.  
  12. # Grab the location of where Hot Mix is on the CD path, especially the
  13. # html dir where all our files for the search engine are.
  14. set CD_PATH $HOTMIXDIR/html
  15. cd $CD_PATH
  16. export CD_PATH
  17.  
  18. # Inform the user of what we're about to do.
  19. cat << 'EOM'
  20.  
  21.  
  22. The Hot Mix 17 CDROM uses a search engine that needs to copy a 
  23. cgi-bin program from the CD to your cgi-bin directory or document 
  24. root, and a search file to your /usr/tmp directory.  
  25.  
  26. This installation program has two modes:
  27. 1.  Automatic.  If you answer yes to the question, "Proceed with 
  28. automatic installation?", the script will try to copy the neccessary
  29. files to their correct locations.
  30. 2.  Custom.  If you answer no to the question, "Proceed with
  31. automatic installation?", the script will ask you if you want
  32. to proceed with a custom installation, and will ask you where
  33. your document root and cgi-bin directories are and will try to
  34. install the neccessary files to their correct locations.
  35.  
  36. >>>Beginning installation process.
  37.  
  38. EOM
  39.  
  40. # Automatic mode.  /var/www is doc root; /var/www/cgi-bin is default.
  41. echo  ">>>Proceed with automatic installation? [yn] $c"
  42. read ans
  43. case $ans in
  44.         y*) echo ""
  45.  
  46. # Informative note only, this info not used by script.
  47.         echo "Checking the server type on your system..."
  48.         if /bin/test -d /var/www/server
  49.         then
  50.           echo "You have an NCSA server on your system."
  51.         else
  52.               if /bin/test -d /usr/ns-home
  53.         then
  54.           echo "You have a Netscape server on your system."
  55.         else
  56.           echo ">>>Can't find NCSA or Netscape servers in the default places."
  57.           echo ">>>Please consult your Webmaster to find out where they may"
  58.           echo ">>>be located on your system, and run the custom install."
  59.               echo ">>>SWISH NOT INSTALLED.  PROGRAM EXITING.<<<"
  60.           exit 1
  61.           fi
  62.         fi
  63.  
  64. # Install things in their expected locations.
  65.           echo ""
  66.           echo "Installing swshsrch.cgi to /var/www/cgi-bin..."
  67.           echo ""
  68.           if /bin/test -w /var/www/cgi-bin
  69.                  then
  70. # Must substitute correct path to CD-based files into your version.
  71.                 /usr/bin/sed s:swish:$CD_PATH/swish.11/swish: $CD_PATH/cgi-bin/swshsrch.cgi > /usr/tmp/tempswish
  72. # Make sure swish looks at an index that's built right.
  73.         if /bin/test -d /CDROM/iso9660
  74.                  then
  75.                   /usr/bin/sed s:index.swish:$CD_PATH/swish.11/indexiso.swish: /usr/tmp/tempswish > /var/www/cgi-bin/swshsrch.cgi
  76.                  else
  77.                   /usr/bin/sed s:index.swish:$CD_PATH/swish.11/index.swish: /usr/tmp/tempswish > /var/www/cgi-bin/swshsrch.cgi
  78.                 fi
  79.                 /usr/bin/rm /usr/tmp/tempswish
  80.                 /usr/bin/chmod 755 /var/www/cgi-bin/swshsrch.cgi
  81.                 /usr/bin/sed s:setup.csh:$HOTMIXDIR/html/setup.csh: $HOTMIXDIR/html/search.html > /usr/tmp/hm17search.html
  82.            else
  83.                 echo ">>>I can't write to that location.  You'll need to log in
  84. as root."
  85.                 echo "Logging in as root...you may need to supply the root password."
  86.                 if /bin/test -d /CDROM/iso9660
  87.                  then
  88.                   su root -c "/usr/bin/sed s:swish:$CD_PATH/swish.11/swish: $CD_PATH/cgi-bin/swshsrch.cgi > /usr/tmp/tempswish;/usr/bin/sed s:index.swish:$CD_PATH/swish.11/indexiso.swish: /usr/tmp/tempswish > /var/www/cgi-bin/swshsrch.cgi;/usr/bin/rm /usr/tmp/tempswish;/usr/bin/chmod 755 /var/www/cgi-bin/swshsrch.cgi;/usr/bin/sed s:setup.csh:$HOTMIXDIR/html/setup.csh: $HOTMIXDIR/html/search.html > /usr/tmp/hm17search.html"
  89.                  else
  90.                 su root -c "/usr/bin/sed s:swish:$CD_PATH/swish.11/swish: $CD_PATH/cgi-bin/swshsrch.cgi > /usr/tmp/tempswish;/usr/bin/sed s:index.swish:$CD_PATH/swish.11/index.swish: /usr/tmp/tempswish > /var/www/cgi-bin/swshsrch.cgi;/usr/bin/rm /usr/tmp/tempswish;/usr/bin/chmod 755 /var/www/cgi-bin/swshsrch.cgi;/usr/bin/sed s:setup.csh:$HOTMIXDIR/html/setup.csh: $HOTMIXDIR/html/search.html > /usr/tmp/hm17search.html"
  91.                 fi
  92.         echo "Finished installing as root...logged out of root account."                echo ""
  93.         fi
  94.         servers=`/sbin/ps -ef | /sbin/grep httpd | /sbin/wc -l`
  95.                 servnum=`echo $servers`
  96.                 case $servnum in
  97.                   0) echo ">>>I don't see an httpd process running for your server."
  98.                      echo ">>>The search engine won't work without a Web server running."
  99.                      echo "Please consult with your Webmaster."
  100.              echo "";;
  101.                 1) echo ">>>I don't see an httpd process running for your server."
  102.                  echo ">>>The search engine won't work without a Web server running."
  103.                      echo "Please consult with your Webmaster."
  104.                  echo "";;
  105.                   *) echo "You appear to have a server running."
  106.              echo ""
  107.              esac
  108.             echo ""
  109.             echo "You should be able to exit this window, reload the Search page" 
  110.         echo "and begin using SWISH.  If SWISH won't work, please consult"
  111.             echo "your Webmaster for help."
  112.             echo ""
  113.             echo ">>>DONE WITH INSTALL<<<"
  114.         exit ;;
  115. #
  116. # Done with default installation.
  117. #
  118.     n*) echo ">>>Proceed with custom installation questions and install? [yn] $c"
  119.         read custom
  120.         case $custom in
  121.          n*) echo ""
  122.          echo ">>>Exiting installation program.  Search engine NOT installed."
  123.          echo ">>>DONE WITH INSTALL<<<"
  124.               exit ;;
  125.          y*) echo ""
  126.          echo ">>>Please type in the full directory path to the "
  127.                  echo "document root on your system."
  128.                  read docroot
  129.          echo ">>>Do you have CGI turned on as a filetype? [yn]"
  130.              read filetype
  131.              case $filetype in 
  132.           y*)  echo ""
  133.                echo "The swshsrch.cgi program will be placed at the top"
  134.                echo "of your document root." 
  135.             putcgihere=$docroot;;
  136.           n*)  echo ""
  137.                echo ">>>This program assumes your cgi-bin directory is under"
  138.                echo "your document root."
  139.                echo "Here is a list of directories with cgi in their name:"
  140.                        cd $docroot
  141.                        find . -type d -name "*cgi*" -print
  142.                        echo ">>>Please type in the primary cgi-bin directory.  Do not include"
  143.                        echo ">>>the leading ./"
  144.                        read wherecgi
  145.                cgiplace=$wherecgi/
  146.                putcgihere=$docroot/$cgiplace
  147.          esac
  148.          export putcgihere 
  149.          export cgiplace
  150.          if /bin/test -w $putcgihere
  151.                    then
  152.              echo ""
  153.                      echo "Copying the program..."
  154.              echo ""
  155.              /usr/bin/sed s:swish:$CD_PATH/swish.11/swish: $CD_PATH/cgi-bin/swshsrch.cgi > /usr/tmp/tempswish
  156.              if /bin/test -d /CDROM/iso9660
  157.                       then
  158.                       /usr/bin/sed s:index.swish:$CD_PATH/swish.11/indexiso.swish: /usr/tmp/tempswish > $putcgihere/swshsrch.cgi
  159.                       else
  160.                       /usr/bin/sed s:index.swish:$CD_PATH/swish.11/index.swish: /usr/tmp/tempswish > $putcgihere/swshsrch.cgi
  161.                      fi
  162.                      /usr/bin/rm /usr/tmp/tempswish
  163.                      /usr/bin/chmod 755 $putcgihere/swshsrch.cgi
  164.              /usr/bin/sed s:cgi-bin/swshsrch.cgi:${cgiplace}swshsrch.cgi: $CD_PATH/search.html > /usr/tmp/tempsearch.html
  165.              /usr/bin/sed s:setup.csh:$HOTMIXDIR/html/setup.csh: /usr/tmp/tempsearch.html > /usr/tmp/hm17search.html
  166.              /usr/bin/rm /usr/tmp/tempsearch.html
  167.                  else
  168.              echo ">>>I can't write to that location.  Hang on a sec...."
  169.                      if /bin/test -d $putcgihere
  170.                          then
  171.                            echo "Directory exists..."
  172.                echo ">>>You'll need to log in as root.  Please supply the"
  173.                echo ">>>root password if asked."
  174.                if /bin/test -d /CDROM/iso9660
  175.                             then
  176.                      su root -c "/usr/bin/sed s:swish:$CD_PATH/swish.11/swish: $CD_PATH/cgi-bin/swshsrch.cgi > /usr/tmp/tempswish; /usr/bin/sed s:index.swish:$CD_PATH/swish.11/indexiso.swish: /usr/tmp/tempswish > $putcgihere/swshsrch.cgi; /usr/bin/rm /usr/tmp/tempswish; /usr/bin/chmod 755 $putcgihere/swshsrch.cgi; /usr/bin/sed s:cgi-bin/swshsrch.cgi:${cgiplace}swshsrch.cgi: $CD_PATH/search.html > /usr/tmp/tempsearch.html; /usr/bin/sed s:setup.csh:$HOTMIXDIR/html/setup.csh: /usr/tmp/tempsearch.html > /usr/tmp/hm17search.html; /usr/bin/rm /usr/tmp/tempsearch.html"
  177.                     else
  178.                      su root -c "/usr/bin/sed s:swish:$CD_PATH/swish.11/swish: $CD_PATH/cgi-bin/swshsrch.cgi > /usr/tmp/tempswish; /usr/bin/sed s:index.swish:$CD_PATH/swish.11/index.swish: /usr/tmp/tempswish > $putcgihere/swshsrch.cgi; /usr/bin/rm /usr/tmp/tempswish; /usr/bin/chmod 755 $putcgihere/swshsrch.cgi; /usr/bin/sed s:cgi-bin/swshsrch.cgi:${cgiplace}swshsrch.cgi: $CD_PATH/search.html > /usr/tmp/tempsearch.html; /usr/bin/sed s:setup.csh:$HOTMIXDIR/html/setup.csh: /usr/tmp/tempsearch.html > /usr/tmp/hm17search.html; /usr/bin/rm /usr/tmp/tempsearch.html"
  179.                     fi
  180.                    echo "Finish installing as root...logged out of root account."
  181.                          else
  182.                echo ""
  183.                            echo ">>>Directory doesn't exist...you'll need to create it and"
  184.                            echo ">>>run the setup script again.  Search engine NOT installed."
  185.                echo ""
  186.                echo ">>>EXITING INSTALL PROGRAM<<<"
  187.                    exit 1;
  188.                  fi
  189.              fi
  190.              servers=`/sbin/ps -ef | /sbin/grep httpd | /sbin/wc -l`
  191.                      servnum=`echo $servers`
  192.                      case $servnum in
  193.                       0) echo ""
  194.               echo ">>>I don't see an httpd process running for your server."
  195.                          echo ">>>The search engine won't work without a Web server running."
  196.                          echo "Please consult with your Webmaster.";;
  197.                       1) echo ">>>I don't see an httpd process running for your server."
  198.                          echo ">>>The search engine won't work without a Web server running."
  199.                          echo "Please consult with your Webmaster.";;
  200.                       *) echo "You appear to have a server running."
  201.                          echo ""
  202.                     esac 
  203.             echo ""
  204.                     echo "You should be able to exit this window, reload the Search page"
  205.                     echo "and begin using SWISH.  If SWISH won't work, please consult"
  206.                     echo "your Webmaster for help."
  207.                     echo ""
  208.                     echo ">>>DONE WITH INSTALL<<<";;
  209.         esac
  210. esac
  211.  
  212.